<?php
include("../includes/db.php");
include("../includes/config.php");
$view=$_GET['view'];
if ($view == 'all')
{
$get_news = "SELECT * FROM NEWS ORDER BY id DESC";
}
else
{
$get_news = "SELECT * FROM NEWS ORDER BY id DESC LIMIT 4";
}
$news = mysql_query($get_news) or die(mysql_error());
?>
<table border="0" align="center">
<?
while ($row = mysql_fetch_array($news)) {
?>
<tr>
<td>
<div align="center">
<b>
<?
echo $row['title'];
?>
</b>
</div>
<hr>
</td>
</tr>
<tr>
<td>
<?
echo $row['message'];
$id=$row['id'];
?>
</td>
</tr>
<tr>
<td>
<font size="-2">
Posted by <?
echo $row['author'];
?> on <?
echo $row['date'];
if (isset($_COOKIE["user"]))
{
$author = $_COOKIE["user"];
$query = "SELECT * FROM users WHERE status='2'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
if ($_COOKIE["user"] == $row['username'])
{
if ($_COOKIE["pass"] ==  $row["password"])
{
echo "&nbsp;<a href='$site_url/news/admin/del.php?id=$id'>Delete</a>";
echo "&nbsp;<a href='$site_url/news/admin/edit.php?id=$id'>Edit</a>";
}
}
}
}
?>
</font>
</td>
</tr>
<?
}
?>
</table>
